import React, { useEffect } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'


const PriviteRouter = ({v}) => {
  const location = useLocation()
  const navigate = useNavigate()
  useEffect(() => {
    const token = localStorage.getItem('token')
    const pathname = location.pathname

    if(pathname !== '/login' && !token) {
      navigate('/login')
    }

  }, [location])

  return <v.element></v.element>
}


export default PriviteRouter